Skip to content

fix(osint): enforce risk-envelope existence and envelope-driven alert budgets in policies#19506

Closed
BrianCLong wants to merge 1 commit intomainfrom
codex/create-osint-source-registry-and-config-files-y1mbwa
Closed

fix(osint): enforce risk-envelope existence and envelope-driven alert budgets in policies#19506
BrianCLong wants to merge 1 commit intomainfrom
codex/create-osint-source-registry-and-config-files-y1mbwa

Conversation

@BrianCLong
Copy link
Copy Markdown
Owner

Motivation

  • Ensure OSINT collection policy gates are aligned with configured risk envelopes so method allowlists and alert budgets are authoritative and deny-by-default.
  • Surface and enforce provenance, privacy, and retention constraints at policy-evaluation time to prevent unauthorized collection or escalation.
  • Provide a minimal, testable lane-1 scaffold (configs, schemas, fixtures, policies, CI, and evidence) so CI can validate governance artifacts deterministically.

Description

  • Added and updated OPA policies to enforce risk envelope existence and to apply envelope-level allowed_methods checks in tos.rego and envelope-driven alert budgets in alert_budget.rego.
  • Added deny-by-default policy modules and unit tests for tos, alert_budget, privacy, and provenance, plus updated fixtures to include risk_envelopes objects for deterministic testing.
  • Introduced OSINT configuration files under config/osint/ (sources.yml, risk_envelopes.yml, retention.yml) and JSON schemas under schemas/osint/ for source registry, risk envelopes, provenance receipts, collection events, and redaction reports.
  • Added a GitHub Actions workflow .github/workflows/osint-governance-verify.yml to install OPA and run opa test plus schema presence checks, and added evidence artifacts and an agent example and prompt registry entries to document scope and verification requirements.

Testing

  • Ran node scripts/check-boundaries.cjs locally and it completed with no boundary violations.
  • Attempted local opa test .github/policies/osint but opa was not available in the execution environment (the workflow is configured to run opa test in CI via the open-policy-agent/setup-opa action).
  • Attempted make smoke (bootstrap) but the local bootstrap failed due to a pip/proxy environment error that prevented dependency installation, so full smoke tests could not complete locally; CI will execute the OPA test suite and the schema presence checks added to the workflow.

Codex Task

@BrianCLong BrianCLong added the codex Codex-owned implementation work label Mar 7, 2026 — with ChatGPT Codex Connector
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request establishes a foundational governance framework for OSINT collection by integrating risk envelopes directly into policy evaluation. It ensures that collection activities adhere to predefined constraints regarding allowed methods, alert budgets, data privacy, and provenance. The changes introduce a deny-by-default approach, supported by new configuration files, JSON schemas, and automated CI checks, to provide a robust and verifiable system for managing OSINT data.

Highlights

  • OPA Policy Enforcement: Implemented new OPA policies to enforce risk envelope existence and apply envelope-level method allowlists and alert budgets for OSINT collection.
  • Deny-by-Default Policies and Tests: Introduced deny-by-default policy modules and comprehensive unit tests for Terms of Service (ToS), alert budgets, privacy, and provenance.
  • OSINT Configuration and Schemas: Added OSINT configuration files (sources.yml, risk_envelopes.yml, retention.yml) and corresponding JSON schemas for robust data validation.
  • Automated CI Workflow: Established a GitHub Actions workflow to automate OPA policy testing and schema presence verification in CI.
  • Evidence and Agent Documentation: Included evidence artifacts and an agent example to document the scope and verification requirements of the new governance framework.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Ignored Files
  • Ignored by pattern: .github/workflows/** (1)
    • .github/workflows/osint-governance-verify.yml
Activity
  • The author ran node scripts/check-boundaries.cjs locally, which completed without boundary violations.
  • Local opa test execution was attempted but failed due to opa not being available in the local environment.
  • Local make smoke (bootstrap) failed due to a pip/proxy environment error preventing dependency installation.
  • CI is configured to execute OPA tests and schema presence checks.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 7, 2026

Warning

Rate limit exceeded

@BrianCLong has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 12 minutes and 41 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 925988f2-a9e0-4ed2-ab52-73b1da99e31e

📥 Commits

Reviewing files that changed from the base of the PR and between 68c99c3 and 7fb3992.

📒 Files selected for processing (46)
  • .github/policies/osint/alert_budget.rego
  • .github/policies/osint/alert_budget_test.rego
  • .github/policies/osint/fixtures/alert_allow_valid.json
  • .github/policies/osint/fixtures/alert_deny_exceeded.json
  • .github/policies/osint/fixtures/alert_deny_unknown_envelope.json
  • .github/policies/osint/fixtures/privacy_allow_valid.json
  • .github/policies/osint/fixtures/privacy_deny_pii.json
  • .github/policies/osint/fixtures/privacy_deny_retention.json
  • .github/policies/osint/fixtures/provenance_allow_valid.json
  • .github/policies/osint/fixtures/provenance_deny_escalation.json
  • .github/policies/osint/fixtures/provenance_deny_missing_artifacts.json
  • .github/policies/osint/fixtures/tos_allow_valid.json
  • .github/policies/osint/fixtures/tos_deny_method.json
  • .github/policies/osint/fixtures/tos_deny_unregistered.json
  • .github/policies/osint/privacy.rego
  • .github/policies/osint/privacy_test.rego
  • .github/policies/osint/provenance.rego
  • .github/policies/osint/provenance_test.rego
  • .github/policies/osint/tos.rego
  • .github/policies/osint/tos_test.rego
  • .github/workflows/osint-governance-verify.yml
  • agents/examples/OSINT_LIMITS_ENVELOPE_PR1.json
  • config/osint/retention.yml
  • config/osint/risk_envelopes.yml
  • config/osint/sources.yml
  • docs/roadmap/STATUS.json
  • evidence/EVD-OSINT-LIMITS-ENVELOPE-POLICY-001/metrics.json
  • evidence/EVD-OSINT-LIMITS-ENVELOPE-POLICY-001/report.json
  • evidence/EVD-OSINT-LIMITS-ENVELOPE-POLICY-001/stamp.json
  • evidence/EVD-OSINT-LIMITS-ENVELOPE-PRIVACY-001/metrics.json
  • evidence/EVD-OSINT-LIMITS-ENVELOPE-PRIVACY-001/report.json
  • evidence/EVD-OSINT-LIMITS-ENVELOPE-PRIVACY-001/stamp.json
  • evidence/EVD-OSINT-LIMITS-ENVELOPE-PROV-001/metrics.json
  • evidence/EVD-OSINT-LIMITS-ENVELOPE-PROV-001/report.json
  • evidence/EVD-OSINT-LIMITS-ENVELOPE-PROV-001/stamp.json
  • evidence/EVD-OSINT-LIMITS-ENVELOPE-SOURCES-001/metrics.json
  • evidence/EVD-OSINT-LIMITS-ENVELOPE-SOURCES-001/report.json
  • evidence/EVD-OSINT-LIMITS-ENVELOPE-SOURCES-001/stamp.json
  • evidence/index.json
  • prompts/governance/osint-guardrails-pr1@v1.md
  • prompts/registry.yaml
  • schemas/osint/collection_event.schema.json
  • schemas/osint/provenance_receipt.schema.json
  • schemas/osint/redaction_report.schema.json
  • schemas/osint/risk_envelopes.schema.json
  • schemas/osint/source_registry.schema.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/create-osint-source-registry-and-config-files-y1mbwa

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive set of OPA policies, configurations, schemas, and tests for OSINT governance. The changes are well-structured and align with the goal of creating a robust, testable, and deny-by-default system. However, a critical 'fail-open' vulnerability has been identified: several individual rules fail to account for missing input fields. This allows an attacker to bypass security checks (e.g., alert budgets, provenance requirements, and method allowlists) by omitting required fields, as OPA comparisons with undefined variables cause rules not to fire. Explicit existence checks (e.g., not input.field) should be added to reject malformed or incomplete inputs. Additionally, there are suggestions to improve the conciseness and maintainability of the new Rego policies.

Comment on lines +9 to +12
deny["alert_budget_exceeded"] if {
envelope := input.risk_envelopes[input.risk_envelope]
input.collection.alert_count > envelope.max_alerts_per_run
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The alert_budget_exceeded rule fails to deny if input.collection.alert_count is missing. In OPA, if a variable used in a comparison is undefined, the entire rule is undefined and does not fire. Since the allow rule (lines 14-16) only checks if there are zero deny results, omitting this field effectively bypasses the alert budget enforcement. You should add an explicit check for the presence of alert_count.

Comment on lines +5 to +17
deny["missing_artifacts"] if {
count(input.collection.provenance.artifact_ids) == 0
}

deny["escalation_single_source"] if {
input.collection.provenance.escalation
input.collection.provenance.single_source
}

deny["insufficient_corroboration"] if {
input.collection.provenance.escalation
input.collection.provenance.corroboration_count < 2
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The provenance policy fails to deny if the input.collection.provenance object is missing. All deny rules in this package depend on fields within input.collection.provenance. If the object is missing, none of the deny rules will fire, and the allow rule (lines 19-21) will evaluate to true. This allows bypassing all provenance requirements (artifact IDs, corroboration counts, etc.) by simply omitting the provenance data.

Comment on lines +13 to +23
deny["method_not_allowed"] if {
source := input.source_registry[input.collection.source_id]
method := input.collection.method
not method_allowed(source.allowed_methods, method)
}

deny["method_not_allowed_by_envelope"] if {
envelope := input.risk_envelopes[input.risk_envelope]
method := input.collection.method
not method_allowed(envelope.allowed_methods, method)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

security-high high

The ToS policy fails to deny if input.collection.method is missing. The rules method_not_allowed (lines 13-17) and method_not_allowed_by_envelope (lines 19-23) will not fire if method is undefined. If the source and envelope are otherwise valid, the policy will allow the request, bypassing the method allowlist checks. You should add an explicit check to ensure the collection method is specified.

Comment on lines +10 to +16
deny["retention_ttl_missing"] if {
not input.collection.retention_ttl_days
}

deny["retention_ttl_missing"] if {
input.collection.retention_ttl_days <= 0
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The two deny rules for checking retention_ttl_days can be combined into a single, more concise rule. This improves readability and maintainability. Also, the key retention_ttl_missing is not fully descriptive for the _ <= 0 case. A key like retention_ttl_invalid would be more accurate.

This single rule correctly handles cases where retention_ttl_days is missing, null, zero, or negative.

deny["retention_ttl_invalid"] if {
  not input.collection.retention_ttl_days > 0
}

Comment on lines +31 to +41
deny["disallowed_tos_method"] if {
input.collection.method == "circumvent"
}

deny["disallowed_tos_method"] if {
input.collection.method == "credential_share"
}

deny["disallowed_tos_method"] if {
input.collection.method == "paywall_bypass"
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The multiple deny["disallowed_tos_method"] rules for hardcoded method names can be consolidated. Using a set of disallowed methods makes the policy more readable and easier to maintain if more methods need to be added in the future.

disallowed_methods := {"circumvent", "credential_share", "paywall_bypass"}

deny["disallowed_tos_method"] if {
  disallowed_methods[input.collection.method]
}

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Auto-approved by Mega Merge Orchestrator

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Auto-approved by Mega Merge Orchestrator

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Auto-approved by Mega Merge Orchestrator

@BrianCLong
Copy link
Copy Markdown
Owner Author

Temporarily closing to reduce Actions queue saturation and unblock #22241. Reopen after the golden-main convergence PR merges.

1 similar comment
@BrianCLong
Copy link
Copy Markdown
Owner Author

Temporarily closing to reduce Actions queue saturation and unblock #22241. Reopen after the golden-main convergence PR merges.

@BrianCLong BrianCLong closed this Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex Codex-owned implementation work queue:blocked

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant